<template>
    <div class="search">
      <van-nav-bar fixed title="相关帖子" left-arrow @click-left="$router.go(-1)" />
  
      <van-search
        readonly
        shape="round"
        background="#ffffff"
        :value="querySearch || '搜索帖子'"
        show-action
        @click="$router.push('/search')"
      >
        <template #action>
          <van-icon class="tool" name="list-switching" />
        </template>
      </van-search>
      <div class="article-list">
        <ArtItem v-for="item in proList" :item="item" :key="item.postId"></ArtItem>
      </div>
    </div>
  </template>
  
  <script>
 import ArtItem from '@/components/ArcItems.vue'
 import { getSearchDate } from '@/api/home'
  export default {
    name: 'SearchIndex',
    data() {
        return {
            page: 1,
            proList: []
        }
    },
    components:{
      ArtItem
     },
     computed: {
      querySearch () {
        return this.$route.query.search
      }
    },
    //获取数据
    async created () {
      const keyword =this.querySearch
      console.log(keyword);
      await getSearchDate(keyword).then((res)=>{
        console.log(res.data);
        this.proList = [res.data]
      })
      console.log('获取的列表数据',this.proList);
    }
  }
  </script>
  
  <style lang="less" scoped>
  .search {
    padding-top: 46px;
    ::v-deep .van-icon-arrow-left {
      color: #333;
    }
  .van-search__content--round{
    height: 40px;
  }
  .van-field{
  margin-top: 5px;
}
em{
  color: #c21401;
}
  
  
  }
  
  </style>